package com.design3.graduatethesissys.mapper;


import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.design3.graduatethesissys.domain.Regist;
import com.design3.graduatethesissys.domain.SysUser;

/** 
* @author 作者 罗穆健: 
* @version 创建时间：2020年1月5日 下午3:12:26 
* 类说明 
*/
@Mapper
public interface SysUserMapper {

	@Select("SELECT id,username,password FROM sys_user WHERE username=#{username};")
	SysUser findByUserName(String userName);
	
	@Select("SELECT name FROM sys_user WHERE username=#{username};")
	String findNameByUserName(String userName);
	
	@Update("update subject set sbj_status = #{sbj_statu} where sbj_id = #{sbj_id}")
	void approveSubject(String sbj_id, String sbj_statu);

	@Update("update sys_user set password=#{newPassword} where username=#{userName}")
	void resetPassword(String newPassword, String userName);

	@Insert("insert into sys_user (id,username,name,password) values(#{id},#{username},#{name},#{password})")
	void InsertUser(Regist regist);

	@Insert("INSERT INTO sys_user_role ( uid, rid )\r\n" + 
			"VALUES\r\n" + 
			"	( #{id}, ( SELECT id FROM sys_role WHERE name = #{role} ) )")
	void InsertUserRole(String id, String role);
}
 